﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace FileDuplicateRemover.Core
{
    public class EntityTreeWalker : IDisposable
    {
        private Action<BaseEntity> ProcessAction;

        public void Walk(DirectoryEntity rootDirectoryEntity, Action<BaseEntity> action)
        {
            ProcessAction = action;
            WalkCore(rootDirectoryEntity);            
        }

        private void WalkCore(DirectoryEntity rootDirectoryEntity)
        {
            foreach (BaseEntity e in rootDirectoryEntity.EntityList)
            {
                ProcessAction(e);

                if (e is DirectoryEntity)
                {
                    WalkCore(e as DirectoryEntity);
                }
            }
        }

        public void Dispose()
        {
        }
    }
}
